<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第二题</title>
</head>

<body>
    <script>
        function getPhone() {
            let max = 0
            let chanpin = 0
            const goods = [
                { uname: '小米', price: 3000 },
                { uname: '苹果', price: 1000 },
                { uname: '华为', price: 10000 },
                { uname: 'oppo', price: 2000 },
                { uname: 'vivo', price: 2000 },
                { uname: '红米', price: 3000 },
                { uname: '诺基亚', price: 500 },
            ]

            for (let i = 0; i < goods.length; i++) {
                if (goods[i].uname === '小米') {
                    document.write(`品牌：${goods[i].uname}<br>价格：${goods[i].price}元`)
                }
                if (max < goods[i].price) {
                    max = goods[i].price
                    chanpin = goods[i]
                }
            }
            console.log(max)
            console.log(chanpin)
            let goods111 = goods.sort((b, a) => a.price - b.price)
            //  console.log(goods111);
            let ass = []
            for (let j = 0; j < goods111.length; j++) {
                if (goods111[j].price > 3000) {
                    ass[j] = goods111[j]
                }
            }
            console.log(ass)
        }
        getPhone()
    </script>
</body>

</html>